    //
//  NCNaviReturnButton.m
//  BaiduTravel
//
//  Created by Neusoft on 11-7-21.
//  Copyright 2011 Neusoft. All rights reserved.
//

#import "NCNaviReturnButton.h"

#import "UIColor-Expanded.h"

@implementation NCNaviReturnButton

#define kBackButtonFontSize			14
#define kNaviBarBackBtnCenter		CGPointMake(25, 22)

#define kHighLightedTextColor		0xFF2D5A8F

- (id)init
{
    self = [super init];
    [self setExclusiveTouch:YES];
    
    return self;
}

/*
 * Init the class with normal string and highlighted string
 */
- (id)superInitWithNormalStateString:(NSString*)normalString withHighlightedStateString:(NSString*)highlightedString
{
    self = [super initWithNormalStateString:normalString withHighlightedStateString:highlightedString];
    return self;
}

- (id)initWithNormalStateString:(NSString*)normalString withHighlightedStateString:(NSString*)highlightedString
{
	self = [super initWithNormalStateString:normalString withHighlightedStateString:highlightedString];
	
	self.offsetX = 2;
	self.offsetY = -1;
	[self setFontSize:kBackButtonFontSize withBolded:YES];
	[self setNormalBackgroundImageFile:@"image_titlebar_back_button.png" 
		   withHighlightedBackgroundImageFile:@"image_titlebar_back_button_pressed.png"];
	self.center = kNaviBarBackBtnCenter;
	[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
	[self setTitleColor:[UIColor colorWithHex:kHighLightedTextColor] forState:UIControlStateHighlighted];
	[self setExclusiveTouch:YES];
    
	return self;
}


/*
 * Init the  class with normal string and highlighted string
 */
- (id)initRectBtnWithNormalStateString:(NSString*)normalString withHighlightedStateString:(NSString*)highlightedString
{
    NSString *normalStr = normalString;
    NSString *highlightedStr = highlightedString;
    if ([normalString length] > 2)
    {
        normalStr = @"返回";
    }
    if (highlightedString && [highlightedString length] > 2)
    {
        highlightedStr = @"返回";
    }
        
	self = [super initWithNormalStateString:normalStr withHighlightedStateString:highlightedStr];
	
	[self setFontSize:kBackButtonFontSize withBolded:YES];
	[self setNormalBackgroundImageFile:@"image_title_button.png" 
	withHighlightedBackgroundImageFile:@"image_title_button_down.png"];
	self.frame = CGRectMake(0, 0, 50, 29);
	self.center = kNaviBarBackBtnCenter;
    self.offsetX = 0;
	[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
	[self setTitleColor:[UIColor colorWithHex:kHighLightedTextColor] forState:UIControlStateHighlighted];
    [self setExclusiveTouch:YES];

	return self;
}

- (void)setNormalStateString:(NSString *)normalString withHighlightedStateString:(NSString *)highlightedString
{
    NSString *normalStr = normalString;
    NSString *highlightedStr = highlightedString;
    if ([normalString length] > 2)
    {
        normalStr = @"返回";
    }
    if (highlightedString && [highlightedString length] > 2)
    {
        highlightedStr = @"返回";
    }
    
    [super setNormalStateString:normalStr withHighlightedStateString:highlightedStr];
}

- (void)dealloc
{
    [super dealloc];
}


@end

@implementation NCNaviReturnButtonWithNoBG

- (id)initRectBtnWithNormalStateString:(NSString*)normalString withHighlightedStateString:(NSString*)highlightedString
{
    NSString *normalStr = normalString;
    NSString *highlightedStr = highlightedString;
    if ([normalString length] > 2)
    {
        normalStr = @"返回";
    }
    if (highlightedString && [highlightedString length] > 2)
    {
        highlightedStr = @"返回";
    }
    
	self = [super superInitWithNormalStateString:normalStr withHighlightedStateString:highlightedStr];
	
	[self setFontSize:kBackButtonFontSize withBolded:YES];
	self.frame = CGRectMake(0, 0, 50, 29);
	self.center = kNaviBarBackBtnCenter;
    self.offsetX = 0;
	[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
	[self setTitleColor:[UIColor colorWithHex:kHighLightedTextColor] forState:UIControlStateHighlighted];
    [self setExclusiveTouch:YES];
    
	return self;
}


@end
